// SensitiveWordMapper.java
package com.acane.instagram.mapper;

import com.acane.instagram.pojo.SensitiveWord;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface SensitiveWordMapper {
    
    // 查询所有敏感词（用于构建AC自动机）
    @Select("SELECT word FROM sensitive_words")
    List<String> getAllWords();

    // 新增敏感词
    @Insert("INSERT INTO sensitive_words (id, word, create_time) " +
            "VALUES (#{id}, #{word}, #{createTime})")
    int insertSensitiveWord(SensitiveWord sensitiveWord);

    // 删除敏感词
    @Delete("DELETE FROM sensitive_words WHERE word = #{word}")
    int deleteByWord(String word);

    // 分页查询（用于管理后台）
    @Select("SELECT * FROM sensitive_words LIMIT #{offset}, #{pageSize}")
    List<SensitiveWord> selectPage(@Param("offset") int offset, 
                                  @Param("pageSize") int pageSize);

    // 根据ID查询（可选）
    @Select("SELECT * FROM sensitive_words WHERE id = #{id}")
    SensitiveWord getById(String id);
}